package com.itheima.model.vo;

import com.itheima.model.domain.User;
import com.itheima.model.domain.UserInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.Date;

/**
 * @author zhangpei
 * @ClassName UserDataVo
 * @date 2022/6/21/9:51
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserDataVo {

    private Integer id;
    private String logo;
    private String logoStatus; //头像状态
    private String nickname;
    private String mobile;
    private String sex;
    private Integer age;
    private String personalSignature; //个性签名
    private String userStatus;
    private Date lastActiveTime=new Date(System.currentTimeMillis()-360000000);  //最近活跃时间
    private String city;

    public static UserDataVo init(UserInfo userInfo, User user) {
        UserDataVo userDataVo = new UserDataVo();
        if (userInfo != null) {
            BeanUtils.copyProperties(userInfo, userDataVo);
            userDataVo.setLogo(userInfo.getAvatar());
            userDataVo.setId(Integer.valueOf(userInfo.getId().toString()));
            userDataVo.setMobile(user.getMobile());
            userDataVo.setSex(userInfo.getGender().equals("woman") ? "女" : "男");
        }
        return userDataVo;
    }
}
